<meta charset="utf-8" />
<div class="box box-primary" id="biz_ahthUser_conatainer">
<div class="box-header with-border">
    <form id="searchForm" role="form" class="form-inline">
      <div class="form-group">
          <label>账户名</label>
            <input name="account" id="account" type="text" placeholder="" class="form-control">
       </div>
       <div class="form-group" >
			<label>所属应用</label>
			<select id="appKey" name="appKey" v-kselect="{url:'auth/authApp/loadAuthAppComboboVo',vmodel:'searchForm.appKey',firstEmpty:'true'}"
			style="width: 170px;" class=" form-control"> </select>
		</div>
        <div class="form-group" id="roleId_div">
        	<label>角色</label>
        	<select id="roleId" name="roleId"
        	 v-kselect="{url:'auth/authRole/loadRoleComboboVo',vmodel:'searchForm.roleId',linkToDomId:'appKey',ajaxParamKey:'appKey',firstEmpty:'true'}" 
        	 style="width: 170px;" class=" form-control"> </select>
		</div> 
        <button type="button"  class="btn btn-info pull-right m-t-n-xs" onclick="search();"><strong>查询</strong></button>
     </form>
</div>
<div class="box-body">
	<div class="row">
			<div class="col-md-12">
				<div class="btn-group " id="authUserTableToolbar" role="group">
					<button type="button" v-kperms="{perm:''}"  class="btn btn-default" v-on:click="add">
                           <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> 添加
                     </button>
                    <!--  <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="edit">
                         <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 修改
                      </button> -->
                      <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="setEnable">
                         <i class="glyphicon glyphicon-ok" aria-hidden="true"></i> 启用
                     </button>
                     <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="setDisable">
                       <i class="glyphicon glyphicon-remove" aria-hidden="true"></i> 禁用
                     </button>
                     <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="roleAssign">
                       <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 角色分配
                     </button>
                      <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="premAssign">
                       <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 权限分配
                     </button>
                     <button type="button"  v-kperms="{perm:''}" class="btn btn-default" v-on:click="resetpwd">
                       <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> 重置密码
                     </button>
           </div>
		<table id="ahthUserBootstrapTable" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
</div>
<script>
 new Vue({  
	  el: '#biz_ahthUser_conatainer',  
	  data:{
		  searchForm:{
			  account: undefined,
			  appKey: undefined,
			  roleId: undefined
		  },
		  bus:new Vue()
	  },
	  mounted:function(){
		 let _this=this;
		 _this.bus.$on(zfesVueDirective.getKselectOnInitEventName("appKey"), function (msg) {
				_this.initTable();
		 });
	  },
   methods: {
 	  initTable:function(){
 		  let columns=[
 				{checkbox:true},
				{field:'account',title:'账户名',width:160,sortable:true},
				{field:'perName',title:'用户名',width:160,sortable:true},
				{field:'defualtRoleName',title:'默认角色',width:160},
				{field:'accountExpired',title:'账户是否过期',width:50,formatter:zfesUtil.formatNoYes},
				{field:'accountLocked',title:'账户是否所定',width:60,formatter:zfesUtil.formatNoYes},
				{field:'credentialsExpired',title:'密码是否过期',width:60,formatter:zfesUtil.formatNoYes},
				{field:'enabled',title:'是否启用',width:60,formatter:zfesUtil.formatEnabled},
				{field:'createTime',title:'创建时间',width:100},
				{field:'description',title:'备注',width:400}];
 		  let url="auth/authUser/loadAuthUserList";
   		zfesBstable.laodTable($("#ahthUserBootstrapTable"),$("#searchForm"),$("#authUserTableToolbar"),url,columns,this.searchForm);
 	  },
 	  search:function(){
 		  zfesBstable.reload($("#ahthUserBootstrapTable")); 
 	  },
 	  refresh:function(){
 		  zfesBstable.refresh($("#ahthUserBootstrapTable"));
 	  },
 	  roleAssign: function(){
 		 if(zfesBstable.isOneRow($("#ahthUserBootstrapTable"))){
 			 let _this=this;
 			 var id=zfesBstable.getRowId($("#ahthUserBootstrapTable"));
 			 var url="/view/auth/authUser/authUser.roleAssign.html";
 			 zfesLayerEditDg.open(url,{"userId":id},"角色分配",1000,function(){_this.refresh();});
 		 }
 	 },
 	 premAssign: function(){
 		 if(zfesBstable.isOneRow($("#ahthUserBootstrapTable"))){
 			 let _this=this;
 			 var id=zfesBstable.getRowId($("#ahthUserBootstrapTable"));
 			 var url="/view/auth/authUser/authUser.prem.assign.html";
 			 zfesLayerEditDg.open(url,{"userId":id},"用户权限分配",1000,function(){_this.refresh();});
 		 }
 	 },
  	 posAssign: function(){
		 if(zfesBstable.isOneRow($("#ahthUserBootstrapTable"))){
			 let _this=this;
			 var id=zfesBstable.getRowId($("#ahthUserBootstrapTable"));
			 var url="/view/auth/authUser/authUser.posAssign.html";
			 zfesLayerEditDg.open(url,{"id":id},"岗位分配",900,function(){_this.refresh();});
		 }
	 },
  	 resetpwd: function(){
		 if(zfesBstable.isOneRow($("#ahthUserBootstrapTable"))){
			 let _this=this;
			 let rows=zfesBstable.getSelections($("#ahthUserBootstrapTable"));
			 let account=rows[0].account;
			 let id=zfesBstable.getRowId($("#ahthUserBootstrapTable"));
			 let url="/view/auth/authUser/authUser.resetpwd.html";
			 zfesLayerEditDg.open(url,{"id":id,account: account},"密码重置",400,function(){_this.refresh();});
		 }
	 },
 	  add:function(){
 		  let　_this=this;
 		 var url="/view/auth/authUser/authUser.add.html";
 		 zfesLayerEditDg.open(url,{},"用户编辑",600,function(){_this.refresh();});
 	  },
 	  edit:function(){
 		  if(zfesBstable.isOneRow($("#ahthUserBootstrapTable"))){
 			  let　_this=this;
 			  let id=zfesBstable.getRowId($("#ahthUserBootstrapTable"));
 			 var url="/view/auth/authUser/authUser.edit.html";
 			  zfesLayerEditDg.open(url,{"id":id},"用户编辑",600,function(){_this.refresh();}); 
 		 }
 	  },
 	  setEnable:function(){
 		  if(zfesBstable.isSelectedRow($("#ahthUserBootstrapTable"))){
 			  let ids=zfesBstable.getRowIds($("#ahthUserBootstrapTable"));
 			  let　_this=this;
 				 alertSwal.confirm("启用","是否执行该操作",function(){
						    let ajaxUrl = "auth/authUser/setUserStatus";
						    zfesAjax.ajaxTodo(ajaxUrl, { "userIds" : ids,"enabled":true}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
							});
						});
 		  }
 	  },
 	  setDisable:function(){
 		  if(zfesBstable.isSelectedRow($("#ahthUserBootstrapTable"))){
 			  let ids=zfesBstable.getRowIds($("#ahthUserBootstrapTable"));
 			  let　_this=this;
 				 alertSwal.confirm("禁用","是否执行该操作",function(){
						    let ajaxUrl = "auth/authUser/setUserStatus";
						    zfesAjax.ajaxTodo(ajaxUrl, { "userIds" : ids,"enabled":false}, function(data) {
								alertSwal.successText(data.message);
								_this.refresh();
						});
 		  		});
 		  }
 	  },
 	  deletex:function(){
 			if(zfesBstable.isOneRow($("#ahthUserBootstrapTable"))){
 				  let　_this=this;
 					var id=zfesBstable.getRowId($("#ahthUserBootstrapTable"));
 					 alertSwal.confirm("删除","是否执行该操作",function(){
 						    let ajaxUrl = "auth/authUser/deletAuthUser";
 							zfesAjax.ajaxTodo(ajaxUrl, { "id" : id}, function(data) {
 								alertSwal.successText(data.message);
 								_this.refresh();
 							},function(data){
 								
 							}); 
 				});
 			}
 				
 	  }
  	
  }

});
</script>
